#!/bin/bash

ft="$1"
shift 1

if [ -z "$ft" ]; then
    echo "editft filetype"
    echo "example:"
    echo "    cat code.rb | editft ruby -"
    exit 1
fi

[ "$ft" == "rb" ] && ft=ruby
[ "$ft" == "erb" ] && ft=erb
[ "$ft" == "py" ] && ft=python
[ "$ft" == "js" ] && ft=javascript
[ "$ft" == "l" ] && ft=lumen
[ "$ft" == "ls" ] && ft=elf
[ "$ft" == "ts" ] && ft=typescript
[ "$ft" == "clj" ] && ft=clojure
[ "$ft" == "md" ] && ft=markdown

cat <<EOS
exec edit -c "set ft=$ft" "$@"
EOS
exec edit -c "set ft=$ft" "$@"

